﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Transport.Core.Models.Customers;
using Transport.Core.Models.Parcels;
using Transport.Core.Models.Settings;

namespace Transport.Areas.Administrator.Models
{
    public class ParcelModel
    {
        public int ParcelId { get; set; }
        [Required(ErrorMessage = "Số vận đơn là bắt buộc.")]
        public string TrackingNumbers { get; set; }
        public string CustomerCode { get; set; }
        public int? CustomerId { get; set; }
        private string _customerName;
        public string CustomerName
        {
            get
            {
                return !CustomerId.HasValue ? "Khách lẻ" : _customerName;
            }
            set
            {
                _customerName = value;
            }
        }
        public int DeliverFromId { get; set; }
        public string DeliverFromName { get; set; }
        [StringLength(128, ErrorMessage = "Địa chỉ tối đa là 128 kí tự.")]
        public string ToAddress { get; set; }
        [StringLength(128, ErrorMessage = "Người nhận tối đa là 128 kí tự.")]
        public string Receiver { get; set; }
        public int DeliverToId { get; set; }
        public string DeliverToName { get; set; }
        public int PostOfficeId { get; set; }
        public int PaymentType { get; set; }
        public int TotalWeight { get; set; }
        public decimal TotalCost { get; set; }
        public string TotalCostDisplay { get { return String.Format("{0:0,0}", TotalCost); } }
        public string TotalCostCollect { get { return TotalCost == 0 ? string.Empty : String.Format("{0:0,0}", TotalCost); } }
        public decimal TotalCostHidden { get; set; }
        public bool IsHandInput { get; set; }
        public DateTime DateOfSending { get; set; }
        public List<Customer> Customers { get; set; }
        public List<Region> Regions { get; set; }
        public List<GroupedSelectListItem> StateProvincesFrom { get; set; }
        public List<GroupedSelectListItem> StateProvincesTo { get; set; }
        public string OfficeName { get; set; }
        public string RegionName { get; set; }
        public bool IsEms { get; set; }
        public bool Collected { get; set; }
        public bool IsApproval { get; set; }
        public string Note { get; set; }
        public string PaymentTypeName
        {
            get
            {
                return PaymentTypes.GetPaymentType(PaymentType);
            }
        }
    }

    public class PackagingGridFilterModel
    {
        public string search { get; set; }
        public int[] ListChecks { get; set; }
    }
}